import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:my_daily_task/features/presentation/cubit/task_cubit.dart';
import 'package:my_daily_task/features/presentation/screens/home_screen.dart';
import 'package:my_daily_task/on_generate_route.dart';
import 'injection_container.dart' as di;

void main() async {
  await di.init();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BlocProvider<TaskCubit>(
      create: (_) => di.sl<TaskCubit>()
        ..openDatabase()
        ..initNotification(),
      child: MaterialApp(
        title: '火鹳提醒',
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: [
          const Locale('zh', 'CN'),
        ],
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
            primaryColor: Colors.indigoAccent, fontFamily: 'zhanghaishan'),
        onGenerateRoute: OnGenerateRoute.route,
        routes: {
          "/": (context) {
            return HomeScreen();
          }
        },
      ),
    );
  }
}
